package com.runshu.rest;

import com.runshu.exception.RestException;

import java.util.HashMap;
import java.util.Map;

/**
 * Created   aa by don-m on 2020-05-04. 
 */
public class RestTestDemo {

    public static void main(String[] args) {

        //初始化调用客户端
        RestClient restClient = new RestClientImpl(5, 10, 2);


        Map<String, String> cookieMap = new HashMap<>();
        cookieMap.put("c1", "v1");
        try {

            // 调用http接口
            String res = restClient.post(
                    "http://api.host/test/api/{restfulKey1}/{restfulKey2}", // 接口地址
                    String.class, //返回值类型
                    ParamBuilder.builder()
                            .put("param1", "value") // 填写urlform 表单参数
                            .put("param2", "value")
                            .put("param3", "value")
                            .build(),
                    cookieMap// cookies
            );

        } catch (RestException e) {
            e.printStackTrace();
        }
    }
}
